
export default {
  state: {
    socket: null,
    capacity: 100, // 数据容量
    collect: [],
    addData: {}
  },

  mutations: {
    'SET_PARK_SOCKET' (state, socket) {
      state.socket = socket
    },
    'UPDATE_PARK_SOCKET_DATA' (state, data) {
      // 控制数据在指定容量范围内
      if (state.collect.length > state.capacity) {
        state.collect.splice(0, state.collect.length - state.capacity + 1)
      }
      state.collect.push(data)
      state.addData = data
    },
    'CHANGE_PARK_COLLECT_CAPACITY' (state, capacity) {
      state.capacity = capacity
    },
    'CLEAR_PARK_COLLECT' (state) {
      state.collcet = []
      state.addData = {}
      state.addAmount = 0
    }
  }
}
